
let config = "http://192.168.1.100:80";

if (process.env.NODE_ENV === "development") {
  config = "http://192.168.1.100:80";
  // config = "http://156.227.1.93:80";
} else {
  config = "http://156.227.1.93:80";
}
// let config = "http://127.0.0.1";
let detailObj = {};

let blursCli = function () {
  window.scroll(0, 0);
}
let returnVal = true;
let formatDateTime = function (date) { 
  var y = date.getFullYear(); 
  var m = date.getMonth() + 1; 
  m = m < 10 ? ('0' + m) : m; 
  var d = date.getDate(); 
  d = d < 10 ? ('0' + d) : d; 
  var h = date.getHours(); 
  h=h < 10 ? ('0' + h) : h; 
  var minute = date.getMinutes(); 
  minute = minute < 10 ? ('0' + minute) : minute; 
  var second=date.getSeconds(); 
  second=second < 10 ? ('0' + second) : second; 
  return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second; 
}; 
let dateZhuan=function(time){
  time = new Date(time).getTime();
  var date = new Date(time + 8 * 3600 * 1000); // 增加8小时
  return date.toJSON().substr(0, 19).replace('T', ' ');
}
let numType=function(num){
  if(Number(num)>=100000){
    return (Number(num)/10000).toFixed(2)+'w'
  }else{
    return num
  }
}
//手机号校验
let checkPhone = function checkPhone(phone){ 
  if(!(/^1[3456789]\d{9}$/.test(phone))){   
      return false; 
  }else{
    return true
  }
}
//密码校验
let passwordCheck = function(str){
  var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,30}');
  
  if (!pwdRegex.test(str)) {
  　return false
  }else{
    return true
  }
}
//手机号四位变星号
let starPhone = function starPhone(phoneNum){
  let str =  String(phoneNum),
  strLen = str.slice(-7,-3);
  return str.replace(strLen,"****");
}


export default {
  config,
  blursCli,
  returnVal,
  formatDateTime,
  checkPhone,
  starPhone,
  passwordCheck,
  dateZhuan,
  numType,
  detailObj
}